import type { App, AsyncComponentLoader } from 'vue';
import { defineAsyncComponent } from 'vue';

const modules = import.meta.glob('@/components/common/*.vue');

export function setupComponents(app: App) {
  for (const [key, value] of Object.entries(modules)) {
    const name = key.slice(key.lastIndexOf('/') + 1, key.lastIndexOf('.'));
    app.component(name, defineAsyncComponent(value as AsyncComponentLoader));
  }
}
